package it.polito.ai.lhmf.orm;



import java.util.Date;
import java.util.HashSet;
import java.util.Set;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import static javax.persistence.GenerationType.IDENTITY;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.UniqueConstraint;

/**
 * Order generated by hbm2java
 */
@Entity
@Table(name = "order", catalog = "malnati_project", uniqueConstraints = @UniqueConstraint(columnNames = "order_name"))
public class Order implements java.io.Serializable {

	private Integer idOrder;
	private Supplier supplier;
	private Member member;
	private String orderName;
	private Date dateOpen;
	private Date dateClose;
	private Date dateDelivery;
	private Set purchases = new HashSet(0);
	private Set messages = new HashSet(0);
	private Set orderProducts = new HashSet(0);

	public Order() {
	}

	public Order(Supplier supplier, Member member, String orderName,
			Date dateOpen, Date dateClose) {
		this.supplier = supplier;
		this.member = member;
		this.orderName = orderName;
		this.dateOpen = dateOpen;
		this.dateClose = dateClose;
	}

	public Order(Supplier supplier, Member member, String orderName,
			Date dateOpen, Date dateClose, Date dateDelivery, Set purchases,
			Set messages, Set orderProducts) {
		this.supplier = supplier;
		this.member = member;
		this.orderName = orderName;
		this.dateOpen = dateOpen;
		this.dateClose = dateClose;
		this.dateDelivery = dateDelivery;
		this.purchases = purchases;
		this.messages = messages;
		this.orderProducts = orderProducts;
	}

	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "idOrder", unique = true, nullable = false)
	public Integer getIdOrder() {
		return this.idOrder;
	}

	public void setIdOrder(Integer idOrder) {
		this.idOrder = idOrder;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "idSupplier", nullable = false)
	public Supplier getSupplier() {
		return this.supplier;
	}

	public void setSupplier(Supplier supplier) {
		this.supplier = supplier;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "idMember_resp", nullable = false)
	public Member getMember() {
		return this.member;
	}

	public void setMember(Member member) {
		this.member = member;
	}

	@Column(name = "order_name", unique = true, nullable = false, length = 100)
	public String getOrderName() {
		return this.orderName;
	}

	public void setOrderName(String orderName) {
		this.orderName = orderName;
	}

	@Temporal(TemporalType.DATE)
	@Column(name = "date_open", nullable = false, length = 10)
	public Date getDateOpen() {
		return this.dateOpen;
	}

	public void setDateOpen(Date dateOpen) {
		this.dateOpen = dateOpen;
	}

	@Temporal(TemporalType.DATE)
	@Column(name = "date_close", nullable = false, length = 10)
	public Date getDateClose() {
		return this.dateClose;
	}

	public void setDateClose(Date dateClose) {
		this.dateClose = dateClose;
	}

	@Temporal(TemporalType.DATE)
	@Column(name = "date_delivery", length = 10)
	public Date getDateDelivery() {
		return this.dateDelivery;
	}

	public void setDateDelivery(Date dateDelivery) {
		this.dateDelivery = dateDelivery;
	}

	@OneToMany(fetch = FetchType.LAZY, mappedBy = "order")
	public Set getPurchases() {
		return this.purchases;
	}

	public void setPurchases(Set purchases) {
		this.purchases = purchases;
	}

	@OneToMany(fetch = FetchType.LAZY, mappedBy = "order")
	public Set getMessages() {
		return this.messages;
	}

	public void setMessages(Set messages) {
		this.messages = messages;
	}

	@OneToMany(fetch = FetchType.LAZY, mappedBy = "order")
	public Set getOrderProducts() {
		return this.orderProducts;
	}

	public void setOrderProducts(Set orderProducts) {
		this.orderProducts = orderProducts;
	}

}
